package networkTopo;
/*
 * NodeGroup.java
 *
 * Created on June 4, 2007, 10:43 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

/**
 *
 * @author Sirius
 */

import java.util.*;
        
public class NodeIDGroup {
    
    public int globalFlag;//-1 if all nodes, 0 if no nodes
    public Vector<Integer> nodeIDs;
    //aa.add(b);
    //aa.addElement(new Integer(a));
    
    //public boolean doIncludeNoneNodes;
    /** Creates a new instance of NodeGroup */
    public NodeIDGroup() {
        globalFlag = 0;
        nodeIDs = new Vector<Integer>();
    }
    
    public void addNodeID(int id) {
        this.globalFlag = 1;
        if (!this.nodeIDs.contains(new Integer(id)))
            this.nodeIDs.addElement(new Integer(id));
        else {
            this.nodeIDs.remove(new Integer(id));
            if (this.nodeIDs.size()==0)
                this.globalFlag = 0;
        } 
            
    }
    
    public boolean isNodeIDIncluded(int id) {
        //this.globalFlag = 1;
        if (!this.nodeIDs.contains(new Integer(id)))
            return false;
        else {
            return true;
        }             
    }
    
    public void clearAllNodeIDs() {
        this.globalFlag = 0;
        this.nodeIDs.removeAllElements();
        //this.nodeIDs.removeAllElements();
    }
    
    public void setGlobalNodeIDs() {
        this.globalFlag = -1;
        //this.nodeIDs.removeAllElements();
    }
    
    public boolean isGlobal() {
        if (this.globalFlag == -1) 
            return true;
        else
            return false;
    }
    
    
}
